
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>JPA中的继承策略 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>JPA中的继承策略 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">JPA 提供了哪三种主要的继承映射策略，它们各自的名称是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">JPA提供了三种主要的继承策略：单表策略（Single Table Strategy）、类表策略（Joined Table Strategy）和具体表策略（Table Per Concrete Class Strategy）。</div>
          </div>
          <div class="card-source">来源: 二、JPA继承策略概述</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在单表继承策略（Single Table Strategy）中，系统是如何区分存储在同一张表中的不同实体类型的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">单表策略通过一个“鉴别器列”（Discriminator Column）来区分不同的实体类型。该列会存储一个特定的值，用于标识每一行数据对应的是哪个子类实体。</div>
          </div>
          <div class="card-source">来源: 2.1 单表策略</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">类表继承策略（Joined Table Strategy）在表结构和查询性能方面有哪些主要特点？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要特点包括：1. 表结构清晰且规范，每个类对应一个表；2. 数据冗余小，子类只存储特有属性；3. 查询复杂度高，因为查询子类时需要进行表连接，可能导致性能较低。</div>
          </div>
          <div class="card-source">来源: 4.1 策略特点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">什么情况下应优先考虑使用单表继承策略（Single Table Strategy）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当继承层次结构中的类差异较小，且大部分字段在子类中都会被使用时；或者当系统对查询性能要求较高，并希望减少表连接操作时，应优先考虑使用单表策略。</div>
          </div>
          <div class="card-source">来源: 3.2 适用场景</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">具体表继承策略（Table Per Concrete Class Strategy）为什么会产生较高的数据冗余？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为在该策略下，每个具体的子类都会映射到一张独立的表，并且这张表会包含该类自身及其所有父类的全部字段。这导致了父类的公共属性在每个子类对应的表中都被重复存储，从而产生数据冗余。</div>
          </div>
          <div class="card-source">来源: 5.1 策略特点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在使用JPA继承策略时，有哪些通用的性能优化建议？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档提出了三点建议：1. 为继承相关的字段（如鉴别器列和外键列）添加适当的索引；2. 批量操作时注意避免产生过多的数据库交互；3. 根据继承策略的特点合理设置缓存策略以提高数据读取效率。</div>
          </div>
          <div class="card-source">来源: 七、性能优化与调优</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
